package top.lshaci.learning.sort;

import java.util.Arrays;

/**
 * MaoPaoSort
 *
 * @author liangxu
 */
public class MaoPaoSort {

    public static void main(String[] args) {
        int[] arr = {7, 5, 6, 3, 5, 1, 2, 9, 5, 8, 4};
        int times = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                }
                System.err.println("第" + ++times + "排序后：" + Arrays.toString(arr));
            }
        }
        System.err.println(Arrays.toString(arr));
    }
}
